package com.onlyxiahui.common.util;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

/**
 * Date 2019-01-11 14:31:40<br>
 * Description 日期工具类
 *
 * @author XiaHui<br>
 * @since 1.0.0
 */
public class OnlyDateUtil {

	public static final String FORMAT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
	public static final String FORMAT_DATE = "yyyy-MM-dd";
	public static final String FORMAT_TIME = "HH:mm:ss";
	public static final String YYYYMMDD = "yyyyMMdd";
	public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

	public static final long SECONDS_IN_DAY = 1000 * 3600 * 24;

	public static final String NUMBER_FORMAT_XX = "00";

	/**
	 * 格式化日期
	 *
	 * @param date
	 * @param pattern
	 * @return String
	 */
	public static String format(Date date, String pattern) {
		String dateTime = null;
		if (date != null && pattern != null) {
			SimpleDateFormat dateFromat = new SimpleDateFormat();
			dateFromat.applyPattern(pattern);
			dateTime = dateFromat.format(date);
		}
		return dateTime;
	}

	/**
	 * 获取当前时间戳
	 *
	 * @return Timestamp
	 */
	public static Timestamp getNowTimestamp() {
		return new Timestamp(System.currentTimeMillis());
	}

	/**
	 * 获取当前日期
	 *
	 * @return Date
	 */
	public static Date getNowDate() {
		return new Date();
	}

	/**
	 * 获取当前日期时间精确到毫秒<br>
	 * 格式 20130401114422555
	 *
	 * @return String
	 */
	public static String getCurrentDateTimeMillis() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		return dateFormat.format(new Date()).toString();
	}

	/**
	 * 获取当前日期时间精确到毫秒<br>
	 * 格式 2013-04-01 11:44:22.555
	 *
	 * @return String
	 */
	public static String getCurrentDateTimeMillisecond() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		return dateFormat.format(new Date()).toString();
	}

	/**
	 * 获取自定义格式的当前日期
	 *
	 * @param format
	 * @return String
	 */
	public static String getCurrentDate(String format) {
		Calendar day = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		String date = sdf.format(day.getTime());
		return date;
	}

	/**
	 * 获取当前日期时间精确到秒<br>
	 * 格式 2013-04-01 11:44:22
	 *
	 * @return String
	 */
	public static String getCurrentDateTime() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return dateFormat.format(new Date());
	}

	/**
	 * 获取当前时间精确到分钟<br>
	 * 格式 2011-06-30 12:30
	 *
	 * @return String
	 */
	public static String getCurrentDateHourMinute() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		return dateFormat.format(new Date());
	}

	/**
	 * 获取当前时间精确到小时<br>
	 * 格式 2011-06-30 12
	 *
	 * @return String
	 */
	public static String getCurrentDateHour() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
		return dateFormat.format(new Date());
	}

	/**
	 * 获取当前日期<br>
	 * 格式2013-04-01
	 *
	 * @return String
	 */
	public static String getCurrentDate() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		return dateFormat.format(new Date());
	}

	/**
	 * 获取当前时间精确到秒<br>
	 * 格式 10:14:33
	 *
	 * @return String
	 */
	public static String getCurrentTime() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
		return dateFormat.format(new Date());
	}

	/**
	 * 获得当前年月 <br>
	 * 格式 2011-06
	 *
	 * @return String
	 */
	public static String getCurrentYearMonth() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
		return dateFormat.format(new Date());
	}

	/**
	 * 获取当前年<br>
	 * 格式2013
	 *
	 * @return String
	 */
	public static String getCurrentYear() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
		return dateFormat.format(new Date());
	}

	/**
	 * 获取当前月<br>
	 * 格式04
	 *
	 * @return String
	 */
	public static String getCurrentMonth() {
		SimpleDateFormat dFormat = new SimpleDateFormat("MM");
		return dFormat.format(new Date());
	}

	/**
	 * 获取当前天<br>
	 * 格式 10
	 *
	 * @return String
	 */
	public static String getCurrentDay() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd");
		return dateFormat.format(new Date());
	}

	/**
	 * 将毫秒转为（HH:mm:ss）多少小时：多少分钟：多少秒
	 *
	 * @param time
	 * @return String
	 */
	public static String millisecondToTime(long time) {
		String text = "";
		time = time / 1000L;
		long hour = time / 3600L;
		long minute = (time - hour * 3600L) / 60L;
		long second = time - hour * 3600L - minute * 60L;
		text = (hour > 9 ? hour : ("0" + hour)) + ":" + (minute > 9 ? minute : ("0" + minute)) + ":"
				+ (second > 9 ? second : ("0" + second));
		return text;
	}

	/**
	 * 时间转字符日期时间精确到秒<br>
	 * 格式2013-04-01 11:44:22
	 *
	 * @return String
	 */
	public static String dateToDateTime(Date date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return dateFormat.format(date);
	}

	/**
	 * 时间转字符日期<br>
	 * 格式2013-04-01
	 *
	 * @return String
	 */
	public static String dateToDate(Date date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		return dateFormat.format(date);
	}

	/**
	 * 时间转字符时间<br>
	 * 格式 10:14:33
	 *
	 * @return String
	 */
	public static String dateToTime(Date date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
		return dateFormat.format(date);
	}

	/**
	 * 时间转字符年<br>
	 * 格式2013
	 *
	 * @return String
	 */
	public static String dateToYear(Date date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
		return dateFormat.format(date);
	}

	/**
	 * 时间转字符月<br>
	 * 格式04
	 *
	 * @return String
	 */
	public static String dateToMonth(Date date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("MM");
		return dateFormat.format(date);
	}

	/**
	 * 时间转字符天<br>
	 * 格式04
	 *
	 * @return String
	 */
	public static String dateToDay(Date date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd");
		return dateFormat.format(date);
	}

	/**
	 * 时间转字符
	 *
	 * @param date
	 * @param format
	 * @return String
	 */
	public static String dateToString(Date date, String format) {
		SimpleDateFormat dateFormat = new SimpleDateFormat(format);
		return dateFormat.format(date);
	}

	/**
	 * yyyy-MM-dd HH:mm:ss转Date
	 *
	 * @param dateTime
	 * @return Date
	 * @throws ParseException
	 */
	public static Date stringDateTimeToDate(String dateTime) throws ParseException {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = dateFormat.parse(dateTime);
		return date;
	}

	/**
	 * yyyy-MM-dd转Date
	 *
	 * @param time
	 * @return Date
	 * @throws ParseException
	 */
	public static Date stringDateToDate(String time) throws ParseException {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Date date = dateFormat.parse(time);
		return date;
	}

	/**
	 * @param dateTime
	 * @param format
	 * @return Date
	 * @throws ParseException
	 */
	public static Date stringDateToDate(String dateTime, String format) throws ParseException {
		DateFormat dateFormat = new SimpleDateFormat(format);
		Date date = dateFormat.parse(dateTime);
		return date;
	}

	/**
	 * String(格式 2011-06-30 12:20:22)转换成时间戳
	 *
	 * @param dateTime
	 * @return long
	 */
	public static long stringDateTimeToLong(String dateTime) throws Exception {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long date = dateFormat.parse(dateTime).getTime();
		return date;
	}

	/**
	 * String(格式 2011-06-30)转换成时间戳
	 *
	 * @param dateTime
	 * @return long
	 */
	public static long stringDateToLong(String dateTime) throws Exception {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		long date = df.parse(dateTime).getTime();
		return date;
	}

	/**
	 * 时间戳转换成String
	 *
	 * @param time
	 * @return String
	 */
	public static String longToString(long time, String format) {
		String date = new SimpleDateFormat(format).format(time);
		return date;
	}

	/**
	 * 时间戳转换成String<br>
	 * 格式 2011-06-30 12:20:22
	 *
	 * @param time
	 * @return String
	 */
	public static String longToDateTimeString(long time) {
		return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);
	}

	/**
	 * 时间戳转换成String 格式 2011-06-30
	 *
	 * @param time
	 * @return String
	 */
	public static String longToDateString(long time) {
		return new SimpleDateFormat("yyyy-MM-dd").format(time);

	}

	/**
	 * 取当月的第一天
	 *
	 * @return String
	 */
	public static String getFirstDayOfCurrentfMonth() {
		return format(new Date(), "yyyy-MM-01");
	}

	/**
	 * 取当月的最后一天
	 *
	 * @return String
	 */
	public static String getLastDayOfCurrentfMonth() {
		Calendar cal = Calendar.getInstance();
		int maxDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
		return format(new Date(), "yyyy-MM-" + maxDay);
	}

	/**
	 * 获取某年某月最后一天
	 *
	 * @param year
	 * @param month
	 * @return int
	 */
	public static int getMonthLastDay(int year, int month) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(year, month - 1, 1);
		return calendar.getActualMaximum(Calendar.DATE);
	}

	/**
	 * 获取某年某月最后一天
	 *
	 * @param year
	 * @param month
	 * @return int
	 */
	public static int getMonthLastDay(String year, String month) {
		return getMonthLastDay(Integer.parseInt(year), Integer.parseInt(month));
	}

	/**
	 * 获取某年某月最后一天
	 *
	 * @param year
	 * @param month
	 * @return int
	 */
	public static int getLastDay(int year, int month) {
		return getMonthLastDay(year, month);
	}

	/**
	 * 获取某年某月最后一天
	 *
	 * @param year
	 * @param month
	 * @return String
	 */
	public static String getLastDay(String year, String month) {
		NumberFormat numberFormat = new DecimalFormat(NUMBER_FORMAT_XX);
		int last = getMonthLastDay(Integer.parseInt(year), Integer.parseInt(month));
		return numberFormat.format(last);
	}

	/**
	 * @param monthOrDay
	 * @return String
	 */
	public static String intMonthOrDayToString(int monthOrDay) {
		NumberFormat numberFormat = new DecimalFormat(NUMBER_FORMAT_XX);
		return numberFormat.format(monthOrDay);
	}

	/**
	 * 将字符串转换成Date 格式可以是以下几种： <br>
	 * yyyy-MM-dd HH:mm:ss<br>
	 * yyyy-MM-dd<br>
	 * yyyyMMdd<br>
	 * HH:mm:ss<br>
	 * yyyyMMdd<br>
	 * HH:mm:ss<br>
	 *
	 * @param dateText ：字符串
	 * @return date
	 */
	public static Date parse(String dateText) {
		Date date = null;
		if (OnlyStringUtil.isNotBlank(dateText)) {
			dateText = OnlyLocalDateUtil.allToDateTimeMillisecond(dateText);
//            String pattern = FORMAT_DATE;
//            if (dateText.indexOf("-") > 0 && dateText.indexOf(":") > 0) {
//                pattern = FORMAT_DATE_TIME;
//            } else if (dateText.indexOf("-") < 0 && dateText.indexOf(" ") > 0 && dateText.indexOf(":") > 0) {
//                pattern = "yyyyMMdd HH:mm:ss";
//            } else if (dateText.indexOf("-") > 0 && dateText.indexOf(":") < 0) {
//                pattern = FORMAT_DATE;
//            } else if (dateText.indexOf("-") < 0 && dateText.indexOf(":") < 0) {
//                pattern = YYYYMMDD;
//            } else if (dateText.indexOf("-") < 0 && dateText.indexOf(":") > 0) {
//                pattern = FORMAT_TIME;
//            }
			SimpleDateFormat dateFormat = new SimpleDateFormat(FORMAT_DATE_TIME);
			try {
				date = dateFormat.parse(dateText);
			} catch (ParseException pe) {
			}
		}
		return date;
	}

	/**
	 * 将字符串转换成Timestamp
	 *
	 * @param dateText 格式化的字符串
	 * @return Timestamp
	 */
	public static Timestamp parseTimestamp(String dateText) {
		Date date = parse(dateText);
		if (date == null) {
			return null;
		} else {
			return new Timestamp(date.getTime());
		}
	}

	/**
	 * 将date格式化成字符串，格式2012-09-12
	 *
	 * @param date ：需要格式化的日期
	 * @return String ：字符串，格式yyyy-MM-dd
	 */
	public static String formatDate(Date date) {
		return format(date, FORMAT_DATE);
	}

	/**
	 * 将date格式化成字符串，格式2012-09-12 14:24:23
	 *
	 * @param date ：需要格式化的日期
	 * @return String ：字符串，格式yyyy-MM-dd HH:mm:ss
	 */
	public static String formatDateTime(Date date) {
		return format(date, FORMAT_DATE_TIME);
	}

	/**
	 * 取得指定日期N天后的日期
	 *
	 * @param date ：指定日期
	 * @param days ：增加的天数，负数表示减
	 * @return date
	 */
	public static Date addDays(Date date, int days) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.DAY_OF_MONTH, days);
		return cal.getTime();
	}

	/**
	 * 获取指定天数后日期<br>
	 * 格式2011-06-30
	 *
	 * @return String
	 */
	public static String getDateByAddDays(int day) {
		Date nowDate = new Date();
		long nowTime = (nowDate.getTime()) + (1000L * 60L * 60L * 24L * day);
		nowDate.setTime(nowTime);
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		return dateFormat.format(nowDate);
	}

	/**
	 * 获取指定天数后日期
	 *
	 * @return String
	 */
	public static String getDateByAddDays(int day, String format) {
		Date nowDate = new Date();
		long nowTime = (nowDate.getTime()) + (long) (1000L * 60L * 60L * 24L * day);
		nowDate.setTime(nowTime);
		SimpleDateFormat dateFormat = new SimpleDateFormat(format);
		return dateFormat.format(nowDate);
	}

	/**
	 * 获取当前星期几
	 *
	 * @return int
	 */
	public static int getCurrentDayOfTheWeek() {
		Calendar calendar = Calendar.getInstance();
		// calendar.setFirstDayOfWeek(Calendar.MONDAY);// 以周一为每周第一天
		calendar.setTime(new Date());
		return calendar.get(Calendar.DAY_OF_WEEK);
	}

	/**
	 * 获取当前日期是当年的第几周
	 *
	 * @return int
	 * @throws ParseException
	 */
	public static int getCurrentWeek() {
		Calendar calendar = Calendar.getInstance();
		// calendar.setFirstDayOfWeek(Calendar.MONDAY);// 以周一为每周第一天
		calendar.setTime(new Date());
		return calendar.get(Calendar.WEEK_OF_YEAR);
	}

	/**
	 * 获取指定日期是当年的第几周
	 *
	 * @param startDate
	 * @return int
	 * @throws ParseException
	 */
	public static int getWeek(String startDate) throws ParseException {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date date = format.parse(startDate);
		Calendar calendar = Calendar.getInstance();
		// calendar.setFirstDayOfWeek(Calendar.MONDAY);// 以周一为每周第一天
		calendar.setTime(date);
		return calendar.get(Calendar.WEEK_OF_YEAR);
	}

	/**
	 * 
	 * Description 获取两个日期之间的间隔天数 <br>
	 * Date 2019-04-01 09:56:30<br>
	 * 
	 * @param start
	 * @param end
	 * @return int
	 * @throws ParseException
	 * @since 1.0.0
	 */
	public static int getBetweenDays(String start, String end) throws ParseException {
		DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date startDate = format.parse(start);
		Date endDate = format.parse(end);
		long days = (endDate.getTime() - startDate.getTime()) / (24L * 60L * 60L * 1000L);
		int betweenDays = Integer.parseInt(days + "");
		return betweenDays;
	}

	/**
	 * 
	 * Description 获取2个时间之间的天数 <br>
	 * Date 2019-04-01 10:07:34<br>
	 * 
	 * @param startDate
	 * @param endDate
	 * @return int
	 * @since 1.0.0
	 */
	public static int getBetweenDays(Date startDate, Date endDate) {
		long days = (endDate.getTime() - startDate.getTime()) / (24L * 60L * 60L * 1000L);
		int betweenDays = Integer.parseInt(String.valueOf(days));
		return betweenDays;
	}

	/**
	 * 
	 * Description 获取时间范围内的所有时间 <br>
	 * Date 2019-04-01 10:07:44<br>
	 * 
	 * @param beginDate
	 * @param endDate
	 * @return List<Date>
	 * @since 1.0.0
	 */
	public static List<Date> getDateList(Date beginDate, Date endDate) {

		List<Date> dateList = new ArrayList<Date>();

		Calendar beginCalendar = Calendar.getInstance();
		beginCalendar.setTime(beginDate);
		beginCalendar.set(Calendar.HOUR_OF_DAY, 0);
		beginCalendar.set(Calendar.MINUTE, 0);
		beginCalendar.set(Calendar.SECOND, 0);
		beginCalendar.set(Calendar.MILLISECOND, 0);
		beginCalendar.add(Calendar.DAY_OF_MONTH, 1);

		// 使用给定的 Date 设置此 Calendar 的时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.setTime(endDate); // 使用给定的 Date 设置此 Calendar 的时间
		endCalendar.set(Calendar.HOUR_OF_DAY, 0);
		endCalendar.set(Calendar.MINUTE, 0);
		endCalendar.set(Calendar.SECOND, 0);
		endCalendar.set(Calendar.MILLISECOND, 0);

		Date end = endCalendar.getTime();

		while (end.after(beginCalendar.getTime())) { // 测试此日期是否在指定日期之后
			Date date = beginCalendar.getTime();// 根据日历的规则，为给定的日历字段添加或减去指定的时间量
			dateList.add(date);
			beginCalendar.add(Calendar.DAY_OF_MONTH, 1);
		}
		return dateList;
	}

	/**
	 * 
	 * Description <br>
	 * Date 2019-04-01 10:08:09<br>
	 * 
	 * @param beginDate
	 * @param endDate
	 * @return List<Date>
	 * @since 1.0.0
	 */
	public static List<Date> getBetweenNotIncludeDateList(Date beginDate, Date endDate) {
		return getDateList(beginDate, endDate);
	}

	/**
	 * 
	 * Description 获取时间范围内的所有时间包含取值的 <br>
	 * Date 2019-04-01 10:08:23<br>
	 * 
	 * @param beginDate
	 * @param endDate
	 * @return List<Date>
	 * @since 1.0.0
	 */
	public static List<Date> getBetweenIncludeDateList(Date beginDate, Date endDate) {
		List<Date> dateList = new ArrayList<Date>();

		Calendar beginCalendar = Calendar.getInstance();
		beginCalendar.setTime(beginDate);
		beginCalendar.set(Calendar.HOUR_OF_DAY, 0);
		beginCalendar.set(Calendar.MINUTE, 0);
		beginCalendar.set(Calendar.SECOND, 0);
		beginCalendar.set(Calendar.MILLISECOND, 0);

		// 使用给定的 Date 设置此 Calendar 的时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.setTime(endDate); // 使用给定的 Date 设置此 Calendar 的时间
		endCalendar.set(Calendar.HOUR_OF_DAY, 0);
		endCalendar.set(Calendar.MINUTE, 0);
		endCalendar.set(Calendar.SECOND, 0);
		endCalendar.set(Calendar.MILLISECOND, 0);

		Date end = endCalendar.getTime();

		while (end.after(beginCalendar.getTime())) { // 测试此日期是否在指定日期之后
			Date date = beginCalendar.getTime();// 根据日历的规则，为给定的日历字段添加或减去指定的时间量
			dateList.add(date);
			beginCalendar.add(Calendar.DAY_OF_MONTH, 1);
		}
		dateList.add(end);
		return dateList;
	}

	/**
	 * 
	 * Description 获取范围内的 <br>
	 * Date 2019-04-01 10:08:38<br>
	 * 
	 * @param beginDate
	 * @param endDate
	 * @return List<Integer>
	 * @since 1.0.0
	 */
	public static List<Integer> getWeekList(Date beginDate, Date endDate) {

		Calendar beginCalendar = Calendar.getInstance();
		beginCalendar.setTime(beginDate); // 使用给定的 Date 设置此 Calendar 的时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.setTime(endDate); // 使用给定的 Date 设置此 Calendar 的时间
		int beginWeek = beginCalendar.get(Calendar.WEEK_OF_YEAR);
		int endWeek = endCalendar.get(Calendar.WEEK_OF_YEAR);
		// endCalendar.get(Calendar.)
		// endCalendar.get(field);
		List<Integer> weekList = new ArrayList<Integer>();
		weekList.add(beginWeek);
		for (int i = beginWeek; i < endWeek; i++) {
			weekList.add(i);
		}
		if (endWeek > beginWeek) {
			weekList.add(endWeek);
		}
		return weekList;
	}

	/**
	 * 
	 * Description 获取当月第一天 <br>
	 * Date 2019-04-01 10:08:52<br>
	 * 
	 * @return Date
	 * @since 1.0.0
	 */
	public static Date getCurrentMonthFirstDay() {
		Calendar calendar = Calendar.getInstance();
		// 设置时间,当前时间不用设置
		// calendar.setTime(new Date());
		// 设置日期为本月最小日期
		calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
		return calendar.getTime();
	}

	/**
	 * 
	 * Description 获取当月最后一天 <br>
	 * Date 2019-04-01 10:09:04<br>
	 * 
	 * @return Date
	 * @since 1.0.0
	 */
	public static Date getCurrentMonthLastDay() {
		Calendar calendar = Calendar.getInstance();
		// 设置时间,当前时间不用设置
		// calendar.setTime(new Date());
		// 设置日期为本月最大日期
		calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
		return calendar.getTime();
	}

	/**
	 * 
	 * Description 判断字符串是否符合时间格式 <br>
	 * Date 2019-04-01 10:09:14<br>
	 * 
	 * @param dateText ：字符串
	 * @return boolean
	 * @since 1.0.0
	 */
	public static boolean isDate(String dateText) {
		if (OnlyStringUtil.isBlank(dateText)) {
			return false;
		} else if (parse(dateText) != null) {
			return true;
		} else {
			return false;
		}
	}

	// //////////////////////////////////////////////////

	/**
	 * 
	 * Description 比较日期大小d1[<]d2 <br>
	 * Date 2019-04-01 10:12:15<br>
	 * 
	 * @param date1
	 * @param date2
	 * @return boolean
	 * @since 1.0.0
	 */
	public static boolean compareDate(String date1, String date2) {
		boolean flag = false;
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd", Locale.CHINA);
			Date d1 = sdf.parse(date1);
			Date d2 = sdf.parse(date2);
			flag = d1.before(d2);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return flag;
	}

	/**
	 * 
	 * Description 比较日期大小d1[<]d2 <br>
	 * Date 2019-04-01 10:11:32<br>
	 * 
	 * @param dateTime1
	 * @param dateTime2
	 * @return boolean
	 * @since 1.0.0
	 */
	public static boolean compareDateTime(String dateTime1, String dateTime2) {
		boolean flag = false;
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);
			Date d1 = sdf.parse(dateTime1);
			Date d2 = sdf.parse(dateTime2);
			flag = d1.before(d2);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return flag;
	}

	/**
	 * 
	 * Description 增加日期天数， 返回格式： yyyy-MM-dd <br>
	 * Date 2019-04-01 10:10:49<br>
	 * 
	 * @param days ：正数加，负数减
	 * @return String
	 * @since 1.0.0
	 */
	public static String getDateByAddDay(int days) {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		Calendar cl = Calendar.getInstance();
		cl.add(Calendar.DAY_OF_MONTH, days);
		return df.format(cl.getTime());
	}

	/**
	 * 
	 * Description 增加日期天数， 返回格式： yyyy-MM-dd <br>
	 * Date 2019-04-01 10:10:24<br>
	 * 
	 * @param days ：正数加，负数减
	 * @param date
	 * @return String
	 * @throws ParseException
	 * @since 1.0.0
	 */
	public static String addDay(int days, String date) throws ParseException {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		Calendar cl = Calendar.getInstance();
		cl.setTime(df.parse(date));
		cl.add(Calendar.DAY_OF_MONTH, days);
		return df.format(cl.getTime());
	}

	/**
	 * 
	 * Description 获取到隔天零点相差的毫秒数 <br>
	 * Date 2019-04-01 10:10:12<br>
	 * 
	 * @return Long
	 * @since 1.0.0
	 */
	public static Long getNowDifferTomorrowZeroMillis() {
		Calendar cl = Calendar.getInstance();
		cl.add(Calendar.DAY_OF_MONTH, 1);
		cl.set(Calendar.HOUR_OF_DAY, 0);
		cl.set(Calendar.MINUTE, 0);
		cl.set(Calendar.SECOND, 0);
		return cl.getTimeInMillis() - System.currentTimeMillis();
	}

	/**
	 * 
	 * Description 获取当前小时 <br>
	 * Date 2019-04-01 10:10:00<br>
	 * 
	 * @return int
	 * @since 1.0.0
	 */
	public static int getNowHour() {
		Calendar cl = Calendar.getInstance();
		return cl.get(Calendar.HOUR_OF_DAY);
	}
}
